Skip to content

Conversation

@1bcMax
Copy link

@1bcMax 1bcMax commented Jan 10, 2026

Summary

Add BlockRun action provider enabling AI agents to access multiple LLM providers (OpenAI, Anthropic, Google, DeepSeek) using pay-per-request USDC micropayments on Base chain via the x402 protocol.

Why BlockRun?

  • Multi-provider access: GPT-4o, Claude, Gemini, DeepSeek via single integration
  • Pay-per-request: No monthly subscriptions - pay only for what you use in USDC
  • Secure: Uses AgentKit's wallet provider - private keys never exposed
  • Native x402: Built on Coinbase's x402 protocol using wallet_provider.to_signer()

Changes

  • Added BlockrunActionProvider with chat_completion, list_models, and get_usdc_balance actions
  • Uses x402 library with AgentKit's wallet provider (same pattern as x402_action_provider)
  • Added USDC balance check before chat completion requests
  • No external SDK dependency - uses built-in x402 support
  • Comprehensive unit tests (32 tests) and e2e test setup

Actions Provided

Action Description
chat_completion Send chat completion requests to LLMs via x402 micropayments
list_models List available models (GPT-4o, Claude, Gemini, DeepSeek)
get_usdc_balance Check wallet's USDC balance on Base before making requests

Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   AgentKit      │     │    BlockRun      │     │   LLM Provider  │
│                 │     │    Action        │     │   (OpenAI,      │
│  WalletProvider │────▶│    Provider      │────▶│   Anthropic,    │
│  .to_signer()   │     │                  │     │   Google, etc)  │
└─────────────────┘     └──────────────────┘     └─────────────────┘
        │                       │
        │                       │ x402 micropayment
        │                       │ (USDC on Base)
        ▼                       ▼
┌─────────────────────────────────────────────┐
│              x402 Protocol                   │
│  - EIP-712 signing via wallet provider       │
│  - Automatic payment handling                │
└─────────────────────────────────────────────┘

Usage Example

from coinbase_agentkit import (
    AgentKit,
    AgentKitConfig,
    blockrun_action_provider,
)

# Works with any EVM wallet provider (CDP, local, etc.)
agentkit = AgentKit(AgentKitConfig(
    wallet_provider=wallet_provider,
    action_providers=[blockrun_action_provider()],
))

# Check balance before making requests
balance = agentkit.run_action("get_usdc_balance", {})

# Make a chat completion request
response = agentkit.run_action("chat_completion", {
    "prompt": "What is the capital of France?",
    "model": "openai/gpt-4o-mini"
})

Testing

  • 32 unit tests pass
  • Ruff linting passes
  • E2E test setup with CDP wallet provider
  • Follows existing action provider patterns (same as x402_action_provider)

Wallet Provider Compatibility

Provider Supported Notes
CdpEvmWalletProvider Recommended - keys managed server-side
EvmWalletProvider Local wallet with private key
Any EVM provider with to_signer() Uses standard interface

Links

Add BlockRun action provider enabling AI agents to access multiple LLM
providers (OpenAI, Anthropic, Google, DeepSeek) using pay-per-request
USDC micropayments on Base chain via the x402 protocol.

Features:
- chat_completion action for LLM inference
- list_models action to discover available models
- Supports Base Mainnet and Sepolia networks
- Uses blockrun-llm SDK for x402 payment handling

Install with: pip install coinbase-agentkit[blockrun]
@1bcMax 1bcMax requested a review from murrlincoln as a code owner January 10, 2026 16:46
@cb-heimdall
Copy link

cb-heimdall commented Jan 10, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions bot added documentation Improvements or additions to documentation action provider New action provider python labels Jan 10, 2026
- Add conftest.py with mock fixtures for wallet_key, wallet_provider, and llm_client
- Add test_blockrun_action_provider.py: 10 tests for initialization, network support, factory
- Add test_chat_completion.py: 7 tests for chat completion action
- Add test_list_models.py: 5 tests for list models action
- Add e2e tests for real API testing (requires BLOCKRUN_WALLET_KEY env var)

All 22 unit tests pass. E2e tests require funded wallet on Base.
Major changes:
- Replace blockrun-llm SDK with x402 library using wallet_provider.to_signer()
- Add get_usdc_balance action to check wallet balance before requests
- Add balance check in chat_completion to prevent failed requests
- Update e2e tests to use CDP wallet provider credentials
- Remove private key exposure - keys are now managed by wallet provider

This follows the same pattern as the existing x402_action_provider,
ensuring BlockRun integrates properly with AgentKit's secure wallet
infrastructure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider documentation Improvements or additions to documentation python

Development

Successfully merging this pull request may close these issues.

2 participants